package com.anosine.gpsl.android.alarm;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;

/**
 * @Title: BootBroadcastReceiver
 * @Package com.anosine.gpsl.android.alarm
 * @Description: 
 * @author: sunny
 * @date: 2015-12-14
 * @version V1.0
 */
public class BootBroadcastReceiver extends BroadcastReceiver {
    private Context mContext; 
    /**
	 * @Title: onReceive(Context context, Intent intent) 
	 * @Description: 继承BroadcastReceiver的子类，重写onReceive方法
	 * @param: context
	 * @param: intent
	 * @return: 无
	 * @throws
	 */
    @Override
    public void onReceive(Context context, Intent intent) {
        mContext = context;
        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
            Handler handler = new Handler(Looper.getMainLooper());
            //after reboot the device,about 2 minutes later,upload the POI info to server            
            handler.postDelayed(new Runnable() {
            	 /**
            	 * @Title: run()
            	 * @Description: 重写run()方法
            	 * @param: 无
            	 * @return: 无
            	 * @throws
            	 */
                @Override
                public void run() {
                    if(!ServiceUtil.isServiceRunning(mContext,Constants.POI_SERVICE)){
                    	//启动
                        ServiceUtil.invokeTimerPOIService(mContext);
                    }
                }
            }, Constants.BROADCAST_ELAPSED_TIME_DELAY);
        }
    }
}

